package org.idea.qiyu.live.framework.redis.starter.key;

import org.idea.qiyu.live.framework.redis.starter.key.common.RedisKeyBuilder;
import org.idea.qiyu.live.framework.redis.starter.key.common.RedisKeyLoadMatch;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-11-04
 * Time: 20:36
 */
@Configuration
@Conditional(RedisKeyLoadMatch.class)
public class GiftProviderCacheKeyBuilder extends RedisKeyBuilder {
    private static final String GIFT_CONSUMER_CACHE_KEY = "gift_consumer";
    private static final String GIFT_PK_CACHE_KEY = "gift_pk";
    private static final String GIFT_SEQ_NUM_CACHE_KEY = "gift_seq_num";
    private static final String RED_PACKET_LIST_CACHE_KEY = "red_packet_list";
    private static final String RED_PACKET_LOCK_CACHE_KEY = "red_packet_lock";

    private static final String RED_PACKET_TOTAL_GET_CACHE_KEY = "red_packet_total_get";
    private static final String RED_PACKET_TOTAL_GET_PRICE_CACHE_KEY = "red_packet_total_get_price";
    private static final String RED_PACKET_MAX_GET_PRICE_CACHE_KEY = "red_packet_max_get_price";

    private static final String RED_PACKET_USER_RECORD_PRICE = "red_packet_user_record_price";
    // 记录红包雨数据是否初始化成功
    private static final String RED_PACKET_PREPARE_SUCCESS = "red_packet_prepare_success";
    // 记录已经开启过了红包雨
    private static final String RED_PACKET_START_SUCCESS = "red_packet_start_success";

    public String buildRedPacketStartSuccessCacheKey(String configCode) {
        return super.getPrefix() + RED_PACKET_START_SUCCESS + super.getSplitItem() + configCode;
    }

    public String buildRedPacketPrepareSuccessCacheKey(String configCode) {
        return super.getPrefix() + RED_PACKET_PREPARE_SUCCESS + super.getSplitItem() + configCode;
    }

    public String buildRedPacketUserRecordPriceCacheKey(Long userId) {
        return super.getPrefix() + RED_PACKET_USER_RECORD_PRICE + super.getSplitItem() + userId;
    }

    public String buildRedPacketTotalGetCacheKey(String code) {
        return super.getPrefix() + RED_PACKET_TOTAL_GET_CACHE_KEY + super.getSplitItem() + code;
    }

    public String buildRedPacketTotalGetPriceCacheKey(String code) {
        return super.getPrefix() + RED_PACKET_TOTAL_GET_PRICE_CACHE_KEY + super.getSplitItem() + code;
    }

    public String buildRedPacketMaxGetPriceCacheKey(String code) {
        return super.getPrefix() + RED_PACKET_MAX_GET_PRICE_CACHE_KEY + super.getSplitItem() + code;
    }

    public String buildRedPacketLockCacheKey(String code) {
        return super.getPrefix() + RED_PACKET_LOCK_CACHE_KEY + super.getSplitItem() + code;
    }

    public String buildRedPacketListCacheKey(String code) {
        return super.getPrefix() + RED_PACKET_LIST_CACHE_KEY + super.getSplitItem() + code;
    }

    public String buildGiftConsumerCacheKey(String uuid) {
        return super.getPrefix() + GIFT_CONSUMER_CACHE_KEY + super.getSplitItem() + uuid;
    }

    public String buildGiftPkCacheKey(Integer roomId) {
        return super.getPrefix() + GIFT_PK_CACHE_KEY + super.getSplitItem() + roomId;
    }

    public String buildGiftSeqNumCacheKey(Integer roomId) {
        return super.getPrefix() + GIFT_SEQ_NUM_CACHE_KEY + super.getSplitItem() + roomId;
    }
}